﻿/// Write a program that concatenates two text files into another text file.

using System;
using System.IO;
using System.Security;


namespace c_sh_II_lek_6_files
{
    class zad1
    {
        static void Main()
        {
            string file1 = @"testStream.txt";
            string file2 = @"concat.txt";
            string newFile = @"concatResult.txt";

            if (File.Exists(newFile))
            {
                File.Delete(newFile);
            }

            using (StreamWriter newAppent = new StreamWriter(newFile))
            {
                using (StreamReader readF1 = new StreamReader(file1))
                {
                    string line = readF1.ReadLine();
                    while (line != null)
                    {
                        newAppent.WriteLine(line);
                        line = readF1.ReadLine();
                    }
                }

                using (StreamReader readF2 = new StreamReader(file2))
                {
                    string line = readF2.ReadLine();
                    while (line != null)
                    {
                        newAppent.WriteLine(line);
                        line = readF2.ReadLine();
                    }
                }
            }
            
        }
    }
}
